package com.lzs.adx.web.modules.adx.controller;


import com.lzs.adx.commmon.utils.Result;
import com.lzs.adx.web.modules.adx.dto.PicPlaterDTO;
import com.lzs.adx.web.modules.adx.dto.PlaterChart;
import com.lzs.adx.web.modules.adx.dto.Total;
import com.lzs.adx.web.modules.adx.dto.VistisTotalDTO;
import com.lzs.adx.web.modules.adx.service.ReportService;
import com.lzs.adx.web.modules.adx.service.ReportTotalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("api/data")
@Api(tags="报表统计")
public class TotalController {


    @Autowired
    private ReportService reportService;




    /**
     * 折线统计：
     *   用户增长数
     *   支付增长数
     */
    @GetMapping("/chart")
    public Result<VistisTotalDTO> lineTotal(){

        return new Result<VistisTotalDTO>().ok(reportService.countChartList());
    }


    @GetMapping("total")
    @ApiOperation("统计全局信息")
    public Result<Total> get(){
        Total totalDto = reportService.totalALlInfo();

        return new Result<Total>().ok(totalDto);
    }

    /**
     * 统计平台使用的数据
     * @return
     */
    @GetMapping("/countProduct")
    public Result<PicPlaterDTO> platerTotal(){
        List<PlaterChart> platerCharts = reportService.countProductTotal();
        List<String> collect = platerCharts.stream().map(t -> t.getName()).collect(Collectors.toList());

        PicPlaterDTO picPlaterDTO=new PicPlaterDTO();
        picPlaterDTO.setColumn(collect);
        picPlaterDTO.setOrderCountDatas(platerCharts);
        return new Result<PicPlaterDTO>().ok(picPlaterDTO);
    }

}
